*** REPLICATION TOOLKIT ***

* AUTHORS: CIMINELLI DUVAL FURCERI 

* ARTICLE: EMPLOYMENT PROTECTION DEREGULATION AND LABOR SHARES IN ADVANCED ECONOMIES 

* JOURNAL: REVIEW OF ECONOMICS AND STATISTICS

* OUTPUT: FIGURE E7 (ONLINE APPENDIX)

***************************

cd ""

use "DTA files/Dataset", clear

**************** PLOT LABOR SHARES BY COUNTRY *******************

gen a = 100*lab/va

* GRAPH LABOR SHARE BY COUNTRY OVER TIME
preserve
collapse (median) median=a (p25) p25=a (p75) p75=a, by(year country) 

egen id = group(country)
sum id
local max = r(max)

* Create matrix having industries as row names (by alphabetic order)
levelsof country, local(m)
mat j=J(`max',1,0)
local nodot: subinstr loc m "." "", all
mat rownames j = `nodot'
mat li j
local nospace: subinstr loc nodot " " "", all
local respace: subinstr loc nospace "'`" "' `", all
mat rownames j = `respace'

* Graph
forvalues i=1/`max' {

* Create local macro with name of the industry 
local names : rownames j
local this_name = "`:word `i' of `names''"

* Create graph
graph twoway line median p25 p75 year if id==`i', title("`this_name'") ////
lpattern(solid dash dash) lwidth (medium thin thin) xtitle("") yla(40(50)100)  xla(1970(10)2015)   ///
legend(label(1 "Median")label(2 "25{superscript:th} pct.")label(3 "75{superscript:th} pct.") size(small)) legend(rows(1)) graphregion(color(white))
graph copy a_country_`i', replace
}
restore

grc1leg a_country_1 a_country_2 a_country_3 a_country_4 a_country_5 a_country_6 a_country_7 a_country_8 a_country_9 //// 
a_country_10 a_country_11 a_country_12 a_country_13 a_country_14 a_country_15 a_country_16 a_country_17 a_country_18 a_country_19 a_country_20 a_country_21 a_country_22, /// 
cols(4) legendfrom(a_country_1) graphregion(color(white)) 
graph export "Figures/E7.png", replace
